
Summary: This example shows how to create 3D-Volume charts in F#.
let's first create some data for the purpose of creating example charts:
open System
open Plotly.NET
let linspace (min,max,n) =
if n <= 2 then failwithf "n needs to be larger then 2"
let bw = float (max - min) / (float n - 1.)
Array.init n (fun i -> min + (bw * float i))
let mgrid (min,max,n) =
let data = linspace(min,max,n)
let z = [|for i in 1 .. n do [|for i in 1 .. n do yield data|]|]
let x = [|for i in 1 .. n do [|for j in 1 .. n do yield [|for k in 1 .. n do yield data.[i-1]|]|]|]
let y = [|for i in 1 .. n do [|for j in 1 .. n do yield [|for k in 1 .. n do yield data.[j-1]|]|]|]
x,y,z
let x,y,z =
mgrid(-8.,8.,40)
|> fun (x,y,z) ->
(x |> Array.concat |> Array.concat),
(y |> Array.concat |> Array.concat),
(z |> Array.concat |> Array.concat)
let values =
Array.map3 (fun x y z ->
sin(x*y*z) / (x*y*z)
) x y z
open Plotly.NET.TraceObjects
let volume =
Chart.Volume(
x, y, z, values,
Opacity=0.1,
Surface=(Surface.init(Count=17)),
IsoMin=0.1,
IsoMax=0.8,
ColorScale = StyleParam.Colorscale.Viridis
)
namespace System
namespace Plotly
namespace Plotly.NET
val linspace : min:float * max:float * n:int -> float []
val min : float
val max : float
val n : int
val failwithf : format:Printf.StringFormat<'T,'Result> -> 'T
<summary>Print to a string buffer and raise an exception with the given
result. Helper printers must return strings.</summary>
<param name="format">The formatter.</param>
<returns>The formatted result.</returns>
val bw : float
Multiple items
val float : value:'T -> float (requires member op_Explicit)
<summary>Converts the argument to 64-bit float. This is a direct conversion for all
primitive numeric types. For strings, the input is converted using <c>Double.Parse()</c>
with InvariantCulture settings. Otherwise the operation requires an appropriate
static conversion method on the input type.</summary>
<param name="value">The input value.</param>
<returns>The converted float</returns>
--------------------
[<Struct>]
type float = Double
<summary>An abbreviation for the CLI type <see cref="T:System.Double" />.</summary>
<category>Basic Types</category>
--------------------
type float<'Measure> =
float
<summary>The type of double-precision floating point numbers, annotated with a unit of measure.
The unit of measure is erased in compiled code and when values of this type
are analyzed using reflection. The type is representationally equivalent to
<see cref="T:System.Double" />.</summary>
<category index="6">Basic Types with Units of Measure</category>
type Array =
interface ICollection
interface IEnumerable
interface IList
interface IStructuralComparable
interface IStructuralEquatable
interface ICloneable
new : unit -> unit
member Clone : unit -> obj
member CopyTo : array: Array * index: int -> unit + 1 overload
member GetEnumerator : unit -> IEnumerator
...
<summary>Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.</summary>
val init : count:int -> initializer:(int -> 'T) -> 'T []
<summary>Creates an array given the dimension and a generator function to compute the elements.</summary>
<param name="count">The number of elements to initialize.</param>
<param name="initializer">The function to generate the initial values for each index.</param>
<returns>The created array.</returns>
<exception cref="T:System.ArgumentException">Thrown when count is negative.</exception>
val i : int
val mgrid : min:float * max:float * n:int -> float [] [] [] * float [] [] [] * float [] [] []
val data : float []
val z : float [] [] []
val x : float [] [] []
val j : int
val k : int
val y : float [] [] []
val x : float []
val y : float []
val z : float []
val concat : arrays:seq<'T []> -> 'T []
<summary>Builds a new array that contains the elements of each of the given sequence of arrays.</summary>
<param name="arrays">The input sequence of arrays.</param>
<returns>The concatenation of the sequence of input arrays.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
val values : float []
val map3 : mapping:('T1 -> 'T2 -> 'T3 -> 'U) -> array1:'T1 [] -> array2:'T2 [] -> array3:'T3 [] -> 'U []
<summary>Builds a new collection whose elements are the results of applying the given function
to the corresponding triples from the three collections. The three input
arrays must have the same length, otherwise an <c>ArgumentException</c> is
raised.</summary>
<param name="mapping">The function to transform the pairs of the input elements.</param>
<param name="array1">The first input array.</param>
<param name="array2">The second input array.</param>
<param name="array3">The third input array.</param>
<exception cref="T:System.ArgumentException">Thrown when the input arrays differ in length.</exception>
<exception cref="T:System.ArgumentNullException">Thrown when any of the input arrays is null.</exception>
<returns>The array of transformed elements.</returns>
val x : float
val y : float
val z : float
val sin : value:'T -> 'T (requires member Sin)
<summary>Sine of the given number</summary>
<param name="value">The input value.</param>
<returns>The sine of the input.</returns>
namespace Plotly.NET.TraceObjects
val volume : GenericChart.GenericChart
type Chart =
static member Area : x:seq<#IConvertible> * y:seq<#IConvertible> * ?Name:string * ?ShowMarkers:bool * ?ShowLegend:bool * ?MarkerSymbol:MarkerSymbol * ?Color:Color * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:DrawingStyle * ?Width:float -> GenericChart + 1 overload
static member Bar : values:seq<#IConvertible> * ?Keys:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:PatternShape * ?MultiPatternShape:seq<PatternShape> * ?Pattern:Pattern * ?Base:#IConvertible * ?Width:'a3 * ?MultiWidth:seq<'a3> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'a4 * ?MultiText:seq<'a4> * ?TextPosition:TextPosition * ?MultiTextPosition:seq<TextPosition> * ?TextFont:Font * ?Marker:Marker -> GenericChart (requires 'a3 :> IConvertible and 'a4 :> IConvertible) + 1 overload
static member BoxPlot : ?x:seq<#IConvertible> * ?y:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Text:'a2 * ?MultiText:seq<'a2> * ?Fillcolor:Color * ?MarkerColor:Color * ?OutlierColor:Color * ?OutlierWidth:int * ?Opacity:float * ?WhiskerWidth:float * ?BoxPoints:BoxPoints * ?BoxMean:BoxMean * ?Jitter:float * ?PointPos:float * ?Orientation:Orientation * ?Marker:Marker * ?Line:Line * ?AlignmentGroup:string * ?Offsetgroup:string * ?Notched:bool * ?NotchWidth:float * ?QuartileMethod:QuartileMethod -> GenericChart (requires 'a2 :> IConvertible) + 1 overload
static member Bubble : x:seq<#IConvertible> * y:seq<#IConvertible> * sizes:seq<int> * ?Name:string * ?ShowLegend:bool * ?MarkerSymbol:MarkerSymbol * ?Color:Color * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart + 1 overload
static member Candlestick : open:seq<#IConvertible> * high:seq<#IConvertible> * low:seq<#IConvertible> * close:seq<#IConvertible> * x:seq<#IConvertible> * ?Increasing:Line * ?Decreasing:Line * ?WhiskerWidth:float * ?Line:Line * ?XCalendar:Calendar -> GenericChart + 1 overload
static member Column : values:seq<#IConvertible> * ?Keys:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?Pattern:Pattern * ?PatternShape:PatternShape * ?MultiPatternShape:seq<PatternShape> * ?Base:#IConvertible * ?Width:'a3 * ?MultiWidth:seq<'a3> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'a4 * ?MultiText:seq<'a4> * ?TextPosition:TextPosition * ?MultiTextPosition:seq<TextPosition> * ?TextFont:Font * ?Marker:Marker -> GenericChart (requires 'a3 :> IConvertible and 'a4 :> IConvertible) + 1 overload
static member Contour : data:seq<#seq<'a1>> * ?X:seq<#IConvertible> * ?Y:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Colorscale:Colorscale * ?Showscale:'a4 * ?zSmooth:SmoothAlg * ?ColorBar:'a5 -> GenericChart (requires 'a1 :> IConvertible)
static member Funnel : x:seq<#IConvertible> * y:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Color:Color * ?Line:Line * ?x0:'a3 * ?dX:float * ?y0:'a4 * ?dY:float * ?Width:float * ?Offset:float * ?Orientation:Orientation * ?Alignmentgroup:string * ?Offsetgroup:string * ?Cliponaxis:bool * ?Connector:FunnelConnector * ?Insidetextfont:Font * ?Outsidetextfont:Font -> GenericChart
static member Heatmap : data:seq<#seq<'a1>> * ?ColNames:seq<#IConvertible> * ?RowNames:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Colorscale:Colorscale * ?Showscale:'a4 * ?Xgap:'a5 * ?Ygap:'a6 * ?zSmooth:SmoothAlg * ?ColorBar:'a7 * ?UseWebGL:bool -> GenericChart (requires 'a1 :> IConvertible)
static member Histogram : ?X:seq<#IConvertible> * ?Y:seq<#IConvertible> * ?Orientation:Orientation * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Text:'a2 * ?MultiText:seq<'a2> * ?HistFunc:HistFunc * ?HistNorm:HistNorm * ?AlignmentGroup:string * ?OffsetGroup:string * ?NBinsX:int * ?NBinsY:int * ?BinGroup:string * ?XBins:Bins * ?YBins:Bins * ?MarkerColor:Color * ?Marker:Marker * ?Line:Line * ?ErrorX:Error * ?ErrorY:Error * ?Cumulative:Cumulative * ?HoverLabel:Hoverlabel -> GenericChart (requires 'a2 :> IConvertible) + 1 overload
...
static member Chart.Volume : x:seq<#IConvertible> * y:seq<#IConvertible> * z:seq<#IConvertible> * value:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?ColorScale:StyleParam.Colorscale * ?ShowScale:bool * ?ColorBar:LayoutObjects.ColorBar * ?IsoMin:float * ?IsoMax:float * ?Caps:Caps * ?Slices:Slices * ?Surface:Surface -> GenericChart.GenericChart
Multiple items
type Surface =
inherit DynamicObj
new : unit -> Surface
static member init : ?Count:int * ?Fill:float * ?Pattern:SurfacePattern * ?Show:bool -> Surface
static member style : ?Count:int * ?Fill:float * ?Pattern:SurfacePattern * ?Show:bool -> (Surface -> Surface)
--------------------
new : unit -> Surface
static member Surface.init : ?Count:int * ?Fill:float * ?Pattern:StyleParam.SurfacePattern * ?Show:bool -> Surface
module StyleParam
from Plotly.NET
type Colorscale =
| Custom of seq<float * string>
| RdBu
| Earth
| Blackbody
| YIOrRd
| YIGnBu
| Bluered
| Portland
| Electric
| Jet
...
member Convert : unit -> obj
static member convert : (Colorscale -> obj)
<summary>
The colorscale must be a collection containing a mapping of a normalized value (between 0.0 and 1.0) to it's color. At minimum, a mapping for the lowest (0.0) and highest (1.0) values are required.
</summary>
union case StyleParam.Colorscale.Viridis: StyleParam.Colorscale
module GenericChart
from Plotly.NET
<summary>
Module to represent a GenericChart
</summary>
val toChartHTML : gChart:GenericChart.GenericChart -> string
<summary>
Converts a GenericChart to it HTML representation. The div layer has a default size of 600 if not specified otherwise.
</summary>